import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.AirlineReservationServiceProxy;
import constants.AirlineReservationServiceConstants;


public class CreateEmployeeServlet extends HttpServlet{
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		AirlineReservationServiceProxy proxy = new AirlineReservationServiceProxy(
				AirlineReservationServiceConstants.SERVICE_URL);
		
		String firstName = req.getParameter("firstName").toUpperCase().trim();
		String lastName =  req.getParameter("lastName").toUpperCase().trim();
		String userName  =  req.getParameter("username").trim();
		String password  =  req.getParameter("password").trim();
		String addressLine1  =  req.getParameter("addressLine1").trim();
		String addressLine2  =  req.getParameter("addressLine2");
		String city  =  req.getParameter("city").trim();
		String state  =  req.getParameter("state").trim();
		String dateOfBirth  =  req.getParameter("dob").trim();
		String workDescription  =  req.getParameter("workDescription").trim();
		String hireDate  =  req.getParameter("hireDate").trim();
		String position  =  req.getParameter("position").trim();
		long zip = Long.parseLong(req.getParameter("zip"));
		String role = req.getParameter("role");
		
		
		proxy.createEmployee(firstName, lastName, userName, password, addressLine1, addressLine2, city, state, dateOfBirth, 0L, "employee", workDescription, hireDate, position, role, 1L, null, 1L, null, zip);
		
		req.setAttribute("createEmployeeSucsess", "Employee Creation Success");
		req.getRequestDispatcher("listEmployees.do").forward(req,resp);
	
	
	}

}
